package mil.af.amc.adpetracker.web.actions.User;

import mil.af.amc.adpetracker.web.actions.AbstractAction;
import mil.af.amc.adpetracker.service.UserService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.DynaActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Action to edit a User's information
 *
 * @author TSgt Jason Ferguson
 */

public class EditUserAction extends AbstractAction {

    private static final Log log = LogFactory.getLog(EditUserAction.class);

    private UserService userService;

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @Override
    public ActionForward execute(ActionMapping actionMapping,
                                 ActionForm actionForm,
                                 HttpServletRequest httpServletRequest,
                                 HttpServletResponse httpServletResponse) throws Exception {


        DynaActionForm form = (DynaActionForm) actionForm;
        userService.editUser(form.getMap());

        return actionMapping.findForward("success");

    }
}
